library(forecastLM)
data("ny_elec")

head(ny_elec)
#>             date_time     y
#> 1 2015-07-01 05:00:00 14444
#> 2 2015-07-01 06:00:00 13809
#> 3 2015-07-01 07:00:00 13435
#> 4 2015-07-01 08:00:00 13144
#> 5 2015-07-01 09:00:00 13147
#> 6 2015-07-01 10:00:00 13771

class(ny_elec)
#> [1] "tbl_ts"     "tbl_df"     "tbl"        "data.frame"
library(TSstudio)

ts_plot(ny_elec,
        title = "Net Generation of Electricity for the New York Region",
        Ytitle = "Megawatthours",
        Xtitle = "Source: US Energy Information Administration (Jan 2020)",
        slider = TRUE)
md1 <- trainLM(input = ny_elec,
               y = "y",
               seasonal = c("month"),
               trend = list(linear = TRUE))


plot_res(md1)
md2 <- trainLM(input = ny_elec,
               y = "y",
               seasonal = c("month", "wday"),
               trend = list(linear = TRUE))


plot_res(md2)
md3 <- trainLM(input = ny_elec,
               y = "y",
               seasonal = c("month", "wday", "hour"),
               trend = list(linear = TRUE))


plot_res(md3)
md4 <- trainLM(input = ny_elec,
               y = "y",
               seasonal = c("month", "wday", "hour"),
               trend = list(linear = TRUE),
               lags = c(1:24))


plot_res(md4)
md5 <- trainLM(input = ny_elec,
               y = "y",
               seasonal = c("month", "wday", "hour"),
               trend = list(linear = TRUE),
               lags = c(1:24, 48, 72))


plot_res(md5)
summary(md5)
#>            Length Class      Mode
#> model      13     lm         list
#> fitted      2     data.frame list
#> residuals   2     tbl_ts     list
#> parameters 13     -none-     list
#> series     32     tbl_ts     list